<template>
  <div class="person">
    <h2>这是一辆{{car.brand}}车，价值{{car.price}}万元</h2>
    <button @click="changePrice">修改价格</button>
    <br>
    <h2>游戏列表</h2>
    <ul>
      <li v-for="g in games" :key="g.id">{{g.name}}</li>
    </ul>
    <button @click="changeFirstGame">修改第一个游戏名字</button>
  </div>
</template>

<script lang="ts" setup name="Person">
  import {reactive} from 'vue'
  // 数据
  let car = reactive({brand:'奔驰',price:100})
  let games = reactive([
    {id:'game01',name:'原神'},
    {id:'game01',name:'明日方舟'},
    {id:'game01',name:'崩坏：星穹铁道'},
  ])
  // 方法
  function changePrice() {
    car.price += 10
  }
  function changeFirstGame() {
    games[0].name = 'Genshin'
  }
</script> 

<style scoped>
  .person {
      background-color: skyblue;
      box-shadow: 0 0 10px;
      border-radius: 10px;
      padding: 20px;
  }

  button {
    margin: 0 5px;
  }
</style>